﻿
/***********
 * modify by oneMax
 * @2008-11-7
********************/
var imgs='';
Pui.photolist={
			f_movephotos:function (){
				//getAbsPoint();
				var objArr = document.getElementsByName("move_check");
				for ( var i=0; i<objArr.length ; i++ )
				{
					if ( objArr[i].checked )
					{
						imgs += objArr[i].value + ",";
					}
				}
				imgs = imgs.substr(0, imgs.length-1 );
				if ( imgs == "" )
				{
					$('#ImgIDsisNull').show(10, function(){ 
							$('#ImgIDsisNull').showDiv();
						});
				}
				else
				{
					imgs = "";
					var albumCount = manageimg.getUserAlbumCount().value;
					if ( albumCount < 2 )  //相册数少于2
					{
						$('#APhotoMove2').show(10, function(){ 
								$('#APhotoMove2').showDiv();
							});
					}
					else
					{
						document.getElementById("useralbumlist").innerHTML=manageimg.getUserAlbum(document.getElementById("hid_albumID").value).value;
						$('#APhotoMove1').show(10, function(){ 
								$('#APhotoMove1').showDiv();
							});
					}
				}
			},
			movephoto:function ()
			{
				var objArr = document.getElementsByName("move_check");
				for ( var i=0; i<objArr.length ; i++ )
				{
					if ( objArr[i].checked )
					{
						imgs += objArr[i].value + ",";
					}
				}
				imgs = imgs.substr(0, imgs.length-1 );
				if ( document.getElementById("sel_album").value == -1 )
				{
					document.getElementById("message_move").innerHTML="请选择转移到的相册";
					return false;
				}
				manageimg.movePhotos(document.getElementById("hid_albumID").value,document.getElementById("sel_album").value,imgs);
				window.location.reload();
			},
			checkinput:function ()
		    {
				if(document.getElementById("txtAlbumName").value.trim()=="")
				{
					alert("相册名字不可以为空！");
					document.getElementById("txtAlbumName").focus();
					return false;
				}
				else
				{
					if( fucCheckLength(document.getElementById("txtAlbumName").value) > 20 )
					{
						alert("相册名字不可以超过10个汉字！");
						document.getElementById("txtAlbumName").focus();
						return false;
					}
				}
				return true;
		    },
		    fucCheckLength:function (strTemp)
			{
				var i,sum;
				sum=0;
				for(i=0;i<strTemp.length;i++)
				{
				if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
				sum=sum+1;
				else
				sum=sum+2;
				}
				return sum;
			},
		    add:function ()
			{
				if(document.getElementById("txtAlbumName").value.trim()=="")
				{
					document.getElementById("message_tr").innerHTML="相册名字不可以为空！";
					document.getElementById("txtAlbumName").focus();
					return false;
				}
				else
				{
					if(this.fucCheckLength(document.getElementById("txtAlbumName").value) > 20 )
					{
						document.getElementById("message_tr").innerHTML="相册名字不可以超过10个汉字！";
						document.getElementById("txtAlbumName").focus();
						return false;
					}
				}
				var result = manageimg.addAlbum(document.getElementById("txtAlbumName").value.trim()).value;
				if ( result == 1 )
				{
					$('#AlbumCreate').hideDiv();  //关闭大层
					//Pra.ui.overlay();//关闭大层
					this.f_movephotos();
				}
				if ( result == 3 )
				{
					document.getElementById("message_tr").innerHTML="该相册已存在！";
				}
			},
			deletephoto:function ( imgID,imgName,uploadid )
			{
				//getAbsPoint();
				document.getElementById("hid_imgID").value=imgID;
				document.getElementById("hid_uploadid").value=uploadid;
				if ( imgName == "" )
				{
					document.getElementById("photoname_sp").innerHTML="该";
				}
				else
				{
					document.getElementById("photoname_sp").innerHTML="["+imgName+"]";
				}
				//添加相册视频的判断
				if ( manageimg.GetAlbumVideoCount(imgID).value == 0 ) 
				{
					$('#APhotoDel').show(10, function(){ 
								$('#APhotoDel').showDiv();
							});
				}
				else
				{
					document.getElementById("photovideoname_sp").innerHTML=manageimg.GetAlbumVideo(imgID).value;
					$('#APhotoDel2').show(10, function(){ 
								$('#APhotoDel2').showDiv();
							});
				}
			},
			delete_Yes:function ()
			{
					var albumID = document.getElementById("hid_albumID").value;
					var result = manageimg.deletePhoto( document.getElementById("hid_imgID").value,albumID,document.getElementById("hid_uploadid").value ).value;
					$('#APhotoDel').hideDiv();  //关闭大层
					//Pra.ui.overlay();//关闭大层
					window.location.reload();
			},
			modifyphoto:function ( imgID ) 
			{
				//getAbsPoint();
				document.getElementById("hid_imgID").value=imgID;
				document.getElementById("APhotoEdit").innerHTML=manageimg.modifyInfo(imgID).value;
				$('#APhotoEdit').show(10, function(){ 
							$('#APhotoEdit').showDiv();
						});
			},
			modifyInfo:function ()
			{
				var result = manageimg.modifyPhotoInfo(document.getElementById("hid_imgID").value,document.getElementById("txtphototitle").value,document.getElementById("photoinfo").value).value;
				$('#APhotoEdit').hideDiv();  //关闭大层
				//Pra.ui.overlay();//关闭大层
				window.location.reload();
			},
			setheadimg:function ( imgID )
			{
				//getAbsPoint();
				document.getElementById("hid_imgID").value=imgID;
				$('#APhotoIndex').show(10, function(){ 
							$('#APhotoIndex').showDiv();
						});
			},
			set_albumheadimg:function ()
			{
				manageimg.setCover(document.getElementById("hid_albumID").value,document.getElementById("hid_imgID").value);
				$('#APhotoIndex').hideDiv();  //关闭大层
				//Pra.ui.overlay();//关闭大层
				window.location.reload();
			},
			setuserheadimg:function ( imgType,setStr)
			{
				//getAbsPoint();
				document.getElementById("Hid_imgType").value=imgType;
				document.getElementById("Hid_setStr").value=setStr;	
				$('#APhotoShow').show(10, function(){ 
							$('#APhotoShow').showDiv();
						});	
			},
			set_userheadimg:function ()
			{
				manageimg.setUserHeadImg(document.getElementById("Hid_imgType").value,document.getElementById("Hid_setStr").value);
				$('#APhotoShow').hideDiv();  //关闭大层
				//Pra.ui.overlay();//关闭大层
				window.location.reload();
			},
			check:function ()
			{
				if ( this.fucCheckLength(document.getElementById("photoinfo").value) > 400 )
				{
					alert("简介最多200汉字！");
					return false;
				}
				else
				{
					return true;
				}
			},
			createAlbum:function ()
			{	
				$('#APhotoMove2').hide();
				document.getElementById("txtAlbumName").value="";
				$('#AlbumCreate').show(10, function(){ 
				$('#AlbumCreate').showDiv();
				}); 
			},
			init:function(){
				$("#MyAlbum .mAlbum").each(function(){
					$(this).hover(function(){
						$(this).addClass("ac");
					},function(){
						$(this).removeClass("ac");
					});
				})
			}
			
}
			
			
			
			

			